<?php
declare(strict_types=1);

namespace App\Controller\Admin\V1\Material;

use App\Controller\Admin\AdminController;
use App\Repositories\MaterialFlowRepository;
use App\Services\AdminService;
use App\Services\MaterialService;
use Hyperf\DbConnection\Db;
use Hyperf\Di\Annotation\Inject;

class FlowController extends AdminController{
    /**
     * @Inject
     * @var AdminService
     */
    public $admin_service;
    /**
     * @Inject
     * @var MaterialService
     */
    public $material_service;

    public function detail(){
        $id = $this->request->input('flow_id',0);
        $flow = MaterialFlowRepository::getInstance()->getById($id);
        return $this->response->success($flow);
    }

    public function verify(){
        $admin = $this->request->getAttribute('admin');
        $data = $this->request->all();
        $result = $this->material_service->verifySheet($data,$admin);
        if(!$result['success']){
            return $this->response->error(10050,$result['msg']);
        }
        return $this->response->success($result);
    }

    public function verifybak(){
        $admin = $this->request->getAttribute('admin');
        $data = $this->request->all();
        $result = $this->material_service->verify($data,$admin);
        if(!$result['success']){
            return $this->response->error(10050,$result['msg']);
        }
        return $this->response->success($result);
    }

    public function score(){
        $admin = $this->request->getAttribute('admin');
        $data = $this->request->all();
        $result = $this->material_service->scoreSheet($data,$admin);
        if(!$result['success']){
            return $this->response->error(10050,$result['msg']);
        }
        return $this->response->success($result);
    }

    public function scorebak(){
        $admin = $this->request->getAttribute('admin');
        $data = $this->request->all();
        $result = $this->material_service->score($data,$admin);
        if(!$result['success']){
            return $this->response->error(10050,$result['msg']);
        }
        return $this->response->success($result);
    }
}